<script type="text/html" template lay-done="layui.data.temporaryUpdatedone(d);">
<div class='temporary-updateHtml-content'>
	<div class="layui-card card-content">
		<div class="layui-card-body layui-form" style="padding: 15px 15px 0 15px;">
			<form class="layui-form temporary-updateHtml-form" action="" lay-filter="temporary-updateHtml-form-group">
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">任务名称：</label>
						<div class="layui-input-inline">
							<input type="text" class="layui-hide" name="id" value='{{d.params.id ? d.params.id : ""}}'>
							<input type="text" value='{{d.params.taskname ? d.params.taskname : ""}}' name="taskname" autocomplete="off" placeholder="请输入标题" class="layui-input">
						</div>
						<span class="icon-important">*</span>
					</div>
					<!-- <div class="layui-inline" style="width:49%;">
						<label class="layui-form-label">是否复核：</label>
						<div class="layui-input-inline"  style="width: 80px;">
							<input {{ d.params.review && d.params.review === '1' ? "checked" : null}} type="checkbox" lay-filter="layui-review-switch" name="review" lay-skin="switch" lay-text="是|否">
						</div>
						<div class="review-content">
							<span class="to-review" >附加复核人：</span>
							{{# if(d.params.review && d.params.review === '1'){ }}
								<div class="review-value-box T-event" data-target="to-review">
									{{# layui.each(d.params.wadduserMsg, function(index, item){ }}
										<span usercode="{{item.adduserdataid}}" certcode="{{item.adduserid}}">{{item.addusername}}</span>
									{{# }) }}
								</div>
							{{# }else{ }}
								<div class="review-value-box layui-bg-gray T-event" data-target="to-review">
									{{# layui.each(d.params.wadduserMsg, function(index, item){ }}
										<span usercode="{{item.adduserdataid}}" certcode="{{item.adduserid}}">{{item.addusername}}</span>
									{{# }) }}
								</div>
							{{# } }}
						</div>
					</div> -->
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">开始日期：</label>
						<div class="layui-input-inline">
							<input type="text" value='{{d.params.starttime ? d.params.starttime : ""}}' readonly name="starttime" class="layui-input temporary-form-group-startDate" lay-verify="date" placeholder="选择时间" autocomplete="off">
						</div>
						<span class="icon-important">*</span>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">结束日期：</label>
						<div class="layui-input-inline">
							<input type="text" value='{{d.params.endtime ? d.params.endtime : ""}}' readonly name="endtime" class="layui-input temporary-form-group-endDate" lay-verify="date" placeholder="选择时间" autocomplete="off">
						</div>
						<span class="icon-important">*</span>
					</div>
				</div>
				<div class="layui-form-item layui-form-text">
					<label class="layui-form-label">填报要求：</label>
					<div class="layui-input-block">
						<textarea name="memo" placeholder="请输入内容" class="layui-textarea" style="min-height: 35px;">
								{{d.params.memo ? d.params.memo : ""}}
						</textarea>
					</div>
				</div>  
			</form>
			<div class="special-content">
				<div class="special-key">
					<form class="dropzone" id="permanent-upload-filie" style="display:none;">
						<div class="fallback" style="display:none;">
							<input type="file" name="file" multiple />
						</div>
					</form>   
					<button type="button" class="layui-btn layui-btn-xs" id="myAwesomeDropzone"><i class="layui-icon"></i>附件</button>
					<!-- <form action='' enctype="multipart/form-data" method="post" id="ieFileUploadForm" name="fileForm"> 
						<label for="upload" style="margin:0;"> 
							<i class="layui-icon"></i>  附件
							<input type="file" id="upload" class="file" name="filename"  accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" style='opacity:0;filter:alpha(opacity=0);'/> 
						</label>                                        
					</form>  -->
					<!-- <button type="button" class="layui-btn layui-btn-xs" id="temporary-upload-filie"><i class="layui-icon"></i>附件</button> -->
				</div>
				<div class="special-value">
					<div class="check-value-box temporary-update-files">
						{{#
							if(d.params.fileMsg && d.params.fileMsg.length > 0){
								layui.each(d.params.fileMsg, function(index,item) {
						}}
								<div class="unit-content">
									<a class="T-event" data-target="download" href="javascript: void(0);" data-url="{{item.url}}">{{item.filename}}</a>
									<i class="layui-icon layui-icon-close T-event" data-target="delFile" data-deptid="{{item.servername}}"></i>
								</div>
						{{#
								})
							}
						}}
					</div>
				</div>
			</div>
			<div class="special-content clearfix" style="position:relative;margin:0;">
				<div class="special-key">
					<button type="button" class="layui-btn layui-btn-xs T-event unit" data-target="unit"><i class="layui-icon">&#xe608;</i>下发单位</button>
				</div>
				<div class="special-value" style="height:70px;margin-bottom:10px;">
					<div class="check-value-box temporary-update-department">
							{{#
								if(d.params.deptMsg || d.params.groupMsg) {
									var exitDep = d.params.deptMsg.length ? d.params.deptMsg : [],
										exGgrp = d.params.groupMsg.length ? d.params.groupMsg : [],
										allEx = exitDep.concat(exGgrp);
									layui.each(allEx, function(index,item) {
							}}
								<div class="unit-content">
									{{item.writeusername}}
									<i class="layui-icon layui-icon-close T-event unit" data-target="delUnit" data-deptid="{{item.dataid}}"></i>
								</div>
							{{#
									})
								}
							}}
					</div>
				</div>
				<span class="icon-important" style="position:absolute;right:-10px;top:25px;">*</span>
			</div>
			<div class="layui-collapse" style="margin-bottom:15px;">
				<div class="layui-colla-item">
				   <h2 class="layui-colla-title c-iframeTitle">表单</h2>
				   <div class="layui-colla-content layui-show iframeContent">
						<iframe id="mainFormIframe" name="TemporaryIframe" class="temporary-updateHtml-form" src="./TemForm/main.html" frameborder="0"></iframe>
				   </div>
				</div>
			</div>
		</div>
	</div>
	<div class="buttons-area">
		<button type="button" class="T-event layui-btn" data-target="add">{{d.params.id ? '修改' : '创建'}}任务</button>
	</div>
</div>
</script>
<style>
.clearfix::after{
	content: '';
	display: block;
	height: 0;
	clear: both;
	visibility: hidden;
}
.temporary-updateHtml-content  .c-iframeTitle {
    height:24px;
    line-height:24px;
    -moz-user-select:none;
    -ms-user-select: none;
    -webkit-user-select: none;
    user-select: none;
    overflow: visible;
}
.temporary-updateHtml-content {
	height: 100%;
	overflow: hidden;
}
.temporary-updateHtml-content .card-content {
	height: 90%;
	overflow: auto;
}
.temporary-updateHtml-content .layui-form-item .layui-inline {
	margin-right: 0px;
}
.temporary-updateHtml-content .layui-form-item .layui-inline{
	width: 40%;
}
.temporary-updateHtml-content .layui-form-item .layui-inline span{
	display: block;
    line-height: 40px;
	height: 0px;
	cursor: pointer;
}
.icon-important{
	color: red;
}
.temporary-updateHtml-content .layui-form-item .layui-input-inline {
    width: 66%;
}
.temporary-updateHtml-content .layui-form-switch {
	background: #D2D2D2;
    width: 60%;
}
.temporary-updateHtml-content .layui-form-switch i {
    background-color: #fff;
}
.temporary-updateHtml-content .layui-form-switch em {
    margin-left: 28px;
    color: #fff!important;
}
.temporary-updateHtml-content .layui-form-onswitch em {
    margin-left: 9px !important;
}
.temporary-updateHtml-content .layui-form-onswitch i {
    margin-left: -22px;
}
.temporary-updateHtml-content .layui-form-onswitch {
    border-color: #2669B1;
    background-color: #2669B1;
}
.temporary-updateHtml-content .layui-btn-xs{
	height: 38px;
    background: #2669B1;
    margin-top: -8px;
    border-radius: 5px;
    width: 75px;
    margin-left: 5px;
	/* -ms-behavior: url(../../dist/style/res/PIE.htc);
	behavior: url(../../dist/style/res/PIE.htc); */
}
.temporary-updateHtml-content .special-content {
	width: 100%;
	margin-bottom: 15px;
}
.temporary-updateHtml-content .special-key {
	overflow: hidden;
	width: 80px;
	float: left;
	padding: 9px 15px;
	text-align: right;
}
.temporary-updateHtml-content .special-value {
	overflow: hidden;
	border: 1px solid #ccc;
	height: 38px;
	border-radius: 6px;
    border: 1px solid rgb(197,197,197);
	/* -ms-behavior: url(../../dist/style/res/PIE.htc);
	behavior: url(../../dist/style/res/PIE.htc); */
}
.temporary-updateHtml-content .layui-input, .layui-textarea{
	height: 35px;
	border-radius: 6px;
    border: 1px solid rgb(197,197,197);
	/* -ms-behavior: url(../../dist/style/res/PIE.htc);
	behavior: url(../../dist/style/res/PIE.htc); */
	padding: 0px 0px 0px 10px;
}
.temporary-updateHtml-content .iframeContent {
	width: 100%;
	height: 475px;
	padding:0px 0px;
}
.temporary-updateHtml-content .iframeContent .temporary-updateHtml-form {
	width: 100%;
	height: 100%;
	overflow: auto;
}
.temporary-updateHtml-content .buttons-area {
	height: 40px;
	text-align: center;
}
.buttons-area button{
	background-color: #2669B1;
}
.temporary-updateHtml-content .check-value-box {
	width: 100%;
	height: 100%;
	overflow-y: auto;
	padding: 2px 2px;
}
.temporary-updateHtml-content .unit-content {
	display: inline-block;
	padding: 2px 5px;
	padding-right: 15px;
	background-color: #ccc;
	position: relative;
	height: 20px;
	line-height: 20px;
	margin-bottom: 5px;
}

.temporary-updateHtml-content .unit-content:hover i{
	visibility: visible;
	color: red;
	font-weight: 600;
}

.temporary-updateHtml-content .unit-content:hover a {
	text-decoration: underline;
}

.temporary-updateHtml-content .unit-content i {
	position: absolute;
	right: 0px;
	top: -2px;
	font-size: 14px;
	cursor: pointer;
	visibility: hidden;
}
.layui-layer{
	border-radius: 8px;
}
.layui-form-label{
	padding: 8px 14px;
}
.layui-layer-setwin{
    top: 10px;
    right: 11px;
}
.layui-layer-setwin .layui-layer-close1{
    background-position: 0 0;
}
.layui-layer-setwin a{
    width: 18px;
    height: 18px;
    margin: 0;
    background: url('/src/style/res/formFill/layer-close.png') no-repeat center center;
    background-position: 0px 0px;
}
.review-content, .audit-content{
	width: 50%;
	float: left;
	position: relative;
}
.to-review, .to-audit{
	position: absolute;
	top: 0;
	left: 0;
}
.review-value-box, .audit-value-box{
	position: absolute;
	left: 83px;
	display: inline-block;
	width: 360px;
	height: 35px;
	line-height: 20px;
	border-radius: 6px;
	margin-left: 10px;
	overflow-y: scroll;
	border: 1px solid #cccccc;
}
.temporary-updateHtml-content .layui-form-item .layui-inline .review-value-box span{
	display: inline-block;
	padding: 2px 5px;
	height: 20px;
	line-height: 20px;
}
.layui-bg-gray{
	background-color: gray;
}
#ieFileUploadForm{
	position: relative;
	height: 38px;
    background: #2669B1;
    margin-top: -8px;
    border-radius: 5px;
    width: 75px;
    margin-left: 5px;
}
#ieFileUploadForm label{
	line-height: 38px;
    font-size: 15px;
    text-align: center; 
    color: #fff;
    width: 100%;
    display: inline-block;
    height: 100%;
}
#ieFileUploadForm #upload{
	opacity: 0; 
	filter:Alpha(opacity=80);
	position: absolute;
    left: 0px;
    top: 0;
	width: 93px;
	height: 100%;
}
</style>
<script src="/start/plugin/jquery.form.js"></script>
<script type="text/html" id="temporaryselectunitTpl">
	{{#
		layui.each(d, function(index,item) {
	}}
		<div class="unit-content">
			<a href="javascript: void(0);">{{item.writeusername}}</a>
			<i class="layui-icon layui-icon-close T-event unit" data-target="delUnit" data-deptid="{{item.dataid}}"></i>
		</div>
	{{#
		})
	}}
</script>
<script type="text/html" id="temporaryselectgroupTpl">
	{{#
		layui.each(d, function(index,item) {
	}}
		<div class="unit-content">
			<a href="javascript: void(0);">{{item.writeusername}}</a>
			<i class="layui-icon layui-icon-close T-event group" data-target="delUnit" data-deptid="{{item.dept_id}}"></i>
		</div>
	{{#
		})
	}}
</script>
<script type="text/html" id="temporaryuploadFilesTpl">
    {{#
        layui.each(d, function(index,item) {
    }}
        <div class="unit-content">
			<a class="T-event" data-target="download" href="javascript: void(0);" data-url="{{item.url}}">{{item.filename}}</a>
            <i class="layui-icon layui-icon-close T-event" data-target="delFile" data-deptid="{{item.servername}}"></i>
        </div>
    {{#
        })
    }}
</script>
<script>
	layui.data.temporaryUpdatedone = function (d) {  
		layui.use(['admin', 'form', 'laydate', 'upload', 'tools', 'set'], function(){
			var $ = layui.$,
			admin = layui.admin,
			view = layui.view,
			element = layui.element,
			layer = layui.layer,
			laydate = layui.laydate,
			laytpl = layui.laytpl,
			upload = layui.upload,
			setter = layui.setter,
			tools = layui.tools,
			filenames = [],
			form = layui.form, 
			uploadFileUrl = 'myapi/DC/api/rest/web/custom/uploadfile';

			layui.factory('set');
			form.render(null, 'temporary-updateHtml-form-group');
			element.render();
			initDom();

			var selectDep = d.params.deptMsg || [],
				selectGrp = d.params.groupMsg || [],
				originDep = [], originGrp = [],
				switchKey = parseInt(d.params.review) || 0;
			$.each(selectDep, function(i,e) {
				e.dept_id = e.dataid;
				originDep.push(e);
			});
			$.each(selectGrp, function(i,e) {
				e.dept_id = e.dataid;
				originGrp.push(e);
			});
			window.selectTable = d.params.formMsg || [];

			if(d.params.id) { //修改
				var exitFileNames = d.params.fileMsg || [];
				if(exitFileNames.length > 0) {
					filenames = exitFileNames;
					var getTpl = temporaryuploadFilesTpl.innerHTML;
					var $tplC =$('.temporary-update-files');
					laytpl(getTpl).render(exitFileNames, function(html){
						$tplC.html(html);
					});
				}
			}

			// var tempFileName = '';
			// upload.render({
			// 	elem: '#temporary-upload-filie',
			// 	accept: 'file',
			// 	url: 'myapi/DC/api/rest/web/custom/uploadfile?access_token='+layui.data('layuiAdmin').access_token,
			// 	choose: function(obj) {
			// 		obj.preview(function(index, file, result){
			// 			tempFileName = file.name;
			// 		});
			// 	},
			// 	done: function(res, index, upload){ //上传后的回调
			// 		if(res.retcode == 0) {
			// 			filenames.push({filename: tempFileName, servername: res.servername});
			// 			var getTpl = temporaryuploadFilesTpl.innerHTML;
			// 			var $tplC =$('.temporary-update-files');
			// 			laytpl(getTpl).render(filenames, function(html){
			// 				$tplC.html(html);
			// 			});
			// 		}else {
			// 			layer.msg('提示: '+ res.retmsg, {time: 1000});
			// 		}
			// 	},
			// 	error: function(index, upload){
			// 		layer.msg('上传文件过大，请重新选择文件上传', {time: 1000});
			// 	}
			// });  
			//dropzone文件上传 
			tools.DropzoneUpload("#myAwesomeDropzone", uploadFileUrl, {}, success = function(res){
				filenames.push({filename: res.filename, servername: res.servername, url: res.url});
				var getTpl = temporaryuploadFilesTpl.innerHTML;
				var $tplC =$('.temporary-update-files');
				laytpl(getTpl).render(filenames, function(html){
					$tplC.html(html);
				});
			}); 
			
			//dom初始化
			function initDom() {
				var startVal = $('.temporary-form-group-startDate').val(),
					endVal = $('.temporary-form-group-endDate').val(),
					commonMin = { year: 1900, month: 0, date: 1},
					commonMax = { year: 2099, month: 11, date: 31};
				var startDate = laydate.render({
					type: 'datetime',
					elem: '.temporary-form-group-startDate',
					min: tools.minDate('date'),
					format: 'yyyy-MM-dd HH:mm',
					done: function (value, date) {
						if(!!value) {
							endDate.config.min = {
								year:date.year,
								month:date.month-1, 
								date: date.date,
							};
						}else {
							endDate.config.min = commonMin;
							endDate.config.max = commonMax;
						}
					}
				});
				var endDate = laydate.render({
					type: 'datetime',
					elem: '.temporary-form-group-endDate',
					format: 'yyyy-MM-dd HH:mm',
					done: function (value, date) {
						if(!!value) {
							startDate.config.max = {
								year: date.year,
								month: date.month - 1,
								date: date.date,
							} 
						}else {
							startDate.config.min = commonMin;
							startDate.config.max = commonMax; 
						}
					}
				});
				!!startVal ? endDate.config.min = tools.commenDate(startVal) : '';
				!!endVal ? startDate.config.max = tools.commenDate(endVal) : '';
			};

			//监听开关
			form.on('switch(layui-review-switch)', function(data){
				if(data.elem.checked){
					switchKey = 1;
					$('.review-value-box').removeClass('layui-bg-gray');
				}else{
					switchKey = 0;
					$('.review-value-box').empty().addClass('layui-bg-gray');
				}
			});

			//监听任务名称输入框
			$('input[name="taskname"]').on('input propertychange', function(){
				var str = $(this).val(),
					length = tools.GetStrLength(str);
				if(length > 256){
					$('input[name="taskname"]').val(str.substr(0, 256));
					layer.msg('任务名称长度不能超过256');
				}
			});

			//监听填报要求输入框
			$('textarea[name="memo"]').on('input propertychange', function(){
				var str = $(this).val(),
					length = tools.GetStrLength(str);
				if(length > 2048){
					$('input[name="memo"]').val(str.substr(0, 2048));
					layer.msg('填报要求长度不能超过2048');
				}
			});


			//加载编辑时已选择的表单
			var mainIframe = document.getElementById('mainFormIframe');
			$(mainIframe).load(function(){
				var iContent = mainIframe.contentWindow;
				if(d.params.formMsg && d.params.formMsg.length > 0){
					var formContanier = iContent.document.querySelector('.select-nodes-list ul'),
						chooseNodes = d.params.formMsg,
						lihtml = '';
					if(chooseNodes && chooseNodes.length > 0){
						for(var i = 0; i < chooseNodes.length; i++){
							if(i == 0){
								lihtml += "<li class='liactive' id='"+chooseNodes[i].id+"' data-model='normal' data-tablename='"+chooseNodes[i].tablename+"' data-formid='"+chooseNodes[i].form_id+"' data-id='"+chooseNodes[i].id+"' data-html='"+chooseNodes[i].html+"'><span>"+chooseNodes[i].formname+"</span><i class='layui-icon layui-icon-close-fill T-btn' data-target='del-form'></i></li>"
							}else{
								lihtml += "<li data-model='normal' id='"+chooseNodes[i].id+"' data-tablename='"+chooseNodes[i].tablename+"' data-formid='"+chooseNodes[i].form_id+"' data-id='"+chooseNodes[i].id+"' data-html='"+chooseNodes[i].html+"'><span>"+chooseNodes[i].formname+"</span><i class='layui-icon layui-icon-close-fill T-btn' data-target='del-form'></i></li>"
							}
						}
						formContanier.innerHTML = lihtml;
						var firstLi = formContanier.querySelector('li');
						firstLi.click();
					}
				}

				//表单预览
				$('#mainFormIframe').contents().find('#preview').click(function(){
					var template = document.createElement('div'),
						formContent = iContent.leipiEditor.getContent(),
						selectNode = iContent.document.querySelector('.liactive');
					template.innerHTML = formContent;
					if(formContent){
						var	cols = iContent.leipiFormDesign.getCols(template);
						layer.open({
							id: 'formView',
							title:'<i class="formFill-icon"></i><span style="color:#FFF;">表单预览</span>',
							offset: '50px',
							type: 1,
							shadeClose: true,
							area: ['1250px', '550px'],
							success: function(lay){
								view(this.id).render('./fill/components/formView',{cols: cols, formname: selectNode.innerText});
							}
						});
					}else{
						layer.msg('请选择表单预览', {time: 1500});
					}
				});
			})

			//页面按钮点击事件 
			$('.temporary-updateHtml-content').on('click', '.T-event', function(e) {  
				var $container = $('.temporary-updateHtml-content'),
					target = $(this).data('target');	
				if(target === 'add') {  
					function getResultArr(originArr, selectArr) {
						var resultArr = [];
						$.each(originArr,function(index, item) {
							var isShowOut = false;
							$.each(selectArr, function(i, e) {
								if(item.dept_id === e.dept_id) {
									item.model = 'normal';
									resultArr.push(item);
									isShowOut = true;
								}
							});
							if(!isShowOut) {
								item.model = 'del';
								resultArr.push(item);
							}
						});
						$.each(selectArr,function(index, item) {
							var isShowInner = false;
							$.each(originArr, function(i, e) {
								if(item.dept_id === e.dept_id) {
									isShowInner = true;
								}
							});
							if(!isShowInner) {
								item.model = 'insert';
								item.taskid = d.params.id || '';
								item.dataid = item.dept_id;
								resultArr.push(item);
							}
						});
						return resultArr;
					}


					//表单信息
					var formMsg = [],
						cols = [],
						myIframe = document.getElementById('mainFormIframe'),
						selectNodes = myIframe.contentWindow.document.querySelectorAll('.select-nodes-list ul li'),
						resultDep = getResultArr(originDep, selectDep),
						args = tools.getAreaArgs($('.temporary-updateHtml-form'), {input: 1}),
						reviewMan = [],
						reviewApply = $('.review-value-box span'),
						delFormMsg = myIframe.contentWindow.document.querySelector('#del-form-container').innerText,
						flag = false;
					
					$.each(selectNodes, function(index, item){
						item.click();
						var model = item.getAttribute('data-model'),
							html = item.getAttribute('data-html'), 
							params = myIframe.contentWindow.reloadTab(html, 'copy'); 
						if(model == 'insert'){
							params.tablename = '';
							params.form_id = '';
							params.id = '';
						}else if(model == 'choose' || model == 'normal'){
							params.model = model;
							params.tablename = item.getAttribute('data-tablename');
							params.form_id = item.getAttribute('data-formid');
							params.id = model == 'normal' ? item.getAttribute('id') : '';
						}
						formMsg.push(params);
					});
					//复核人信息
					if(reviewApply){
						$.each(reviewApply, function(index, item){
							reviewMan.push({ user_code: item.getAttribute('usercode'), userName: item.innerText, cert_code: item.getAttribute('certcode') })
						})
					}
					//下发单位信息
					if(resultDep){
						layui.each(resultDep, function(index, item){
							if(item.model != 'del' ){
								flag = true;
								return ;
							}
						})
					} 
					args.fileNames = JSON.stringify(filenames);
					args.deptMsg = JSON.stringify(resultDep);
					args.formMsg = JSON.stringify(formMsg);
					args.wadduserMsg = JSON.stringify(reviewMan);
					args.model = 'insert';
					args.updatedata = '0';
					args.tasktype = 'ls';
					args.username = '';
					args.userid = '';
					args.filename = '';
					args.servername = '';
					args.deptname = '';
					args.deptid = '';
					args.jsonId = layui.data('layuiAdmin').access_token;
					args.link = '';
					!args.review ? args.review = 1 : '';
					if(!!d.params.id) {
						args.model = 'update';
						args.updatedata = '1';
					}
					if(args.taskname == ''){ layer.msg('请填写任务名称');return false; }
					if(args.starttime == ''){ layer.msg('请填写任务开始日期');return false; }
					if(args.endtime == ''){ layer.msg('请填写任务结束日期');return false; }
					if(!flag){ layer.msg('请选择下发单位');return false; }
					if(formMsg && formMsg.length <= 0){ layer.msg('请选择表单');return false; }
					admin.req({
						url: 'myapi/DC/api/rest/web/custom/TemporaryTask',
						type: 'post',
						data: args,
						success: function(res){
							layer.msg(res.data.retmsg, {time: 1000});
							if(res.data.retcode == '0'){
								window.selectTable = [];
								tools.destroyIframe(myIframe);
								layer.closeAll('page');
								d.params.callBack && d.params.callBack();
							}
						}
					});
				}else if(target === 'unit') {
					var temporaryUrl = "./task/temporary/past";
					layer.open({
						id: 'temporary-add-pastHtml',
						title:'<i class="formFill-icon"></i><span style="color:#FFF;">任务下发</span>',
						offset: '100px',
						type: 1,
						shadeClose: true,
						resize: false,
						area: ['450px', '650px'],
						success: function(lay, index) {
							view(this.id).render(temporaryUrl, {
								exitDep: selectDep,
							}).done(function() {
								$(lay).on('click', '.T-confirm', function() {
									selectDep = JSON.parse($(lay).find('.data-dep-container').val());
									var depNameStr = selectDep;
									var getTpl = temporaryselectunitTpl.innerHTML;
									var $tplC =$('.temporary-update-department');
									laytpl(getTpl).render(depNameStr, function(html){
										$tplC.html(html);
									});
									layer.close(index);
								});
							});
						}
					});
				} else if(target === 'delUnit') {
					var depid = $(this).data('deptid');
					delArr();
					function delArr() {
						var filterDep = [];
						$.each(selectDep, function(index) {
							if(selectDep[index].dept_id !== depid) {
								filterDep.push(selectDep[index]);
							}
						});
						selectDep = filterDep;
						depNameStr = selectDep;
						var getTpl = temporaryselectunitTpl.innerHTML;
						var $tplC =$('.temporary-update-department');
						laytpl(getTpl).render(depNameStr, function(html){
							$tplC.html(html);
						});
					}
				} else if (target === 'delFile') {
					var depid = $(this).data('deptid');
					admin.req({
						url: 'myapi/DC/api/rest/web/custom/Resident/delfile',
						type: 'post',
						data: {
							servername: depid,
							jsonId: layui.data('layuiAdmin').access_token
						},
						success: function(res){
							if(res.retcode == 0) {
								var filterFiles = [];
								$.each(filenames, function(index) {
									if(filenames[index].servername !== depid) {
										filterFiles.push(filenames[index]);
									}
								});
								filenames = filterFiles;
								var getTpl = temporaryuploadFilesTpl.innerHTML;
								var $tplC =$('.temporary-update-files');
								laytpl(getTpl).render(filenames, function(html){
									$tplC.html(html);
								});
							}
						}
					});
				}else if (target === 'download') {
					var url = 'myapi/DC'+ $(this).data('url'),
						name = $(this).text();
					tools.downMethodfunction(url, name);
				}else if(target == 'to-review'){
					var text = $(this).siblings('span').text(),
						reviewUrl = null,
						selectPerson = $('.review-value-box span'),
						selectIds = [];
					if(switchKey == 0){
						return false
					}else{
						reviewUrl = text === '附加复核人：' ? './task/temporary/addPerson' : './task/temporary/pullPerson';
						if(selectPerson){
							layui.each(selectPerson, function(index, item){
								selectIds.push({ 
									dept_name: item.getAttribute('deptname'),
									userName: item.innerText,
									user_code: item.getAttribute('usercode'), 
									phone: item.getAttribute('phone'),
									email: item.getAttribute('email'),
									cert_code: item.getAttribute('certcode')
								});
							})
						}
						layer.open({
							id: 'temporary-reviewHtml',
							title: '<i class="formFill-icon"></i><span style="color:#FFF;">'+text+'</span>',
							type: 1,
							offset: '20px',
							shadeClose: true,
							area: ['570px', '650px'],
							success: function(lay, index){
								view(this.id).render(reviewUrl, {
									checkIds: selectIds || []
								}).done(function() {
									$(lay).on('click', '.T-confirm', function() {
										if(text == "附加复核人："){
											var selectReview = $(lay).find('.check-value-box .unit-content'),
												$eachman = '';
											$.each(selectReview, function(index, item){
												var usercode = item.querySelector('.del-tag').getAttribute('data-usercode'),
													certcode = item.querySelector('.del-tag').getAttribute('data-certcode'),
													deptname = item.querySelector('.del-tag').getAttribute('data-deptnme'),
													phone = item.querySelector('.del-tag').getAttribute('data-phone'),
													email = item.querySelector('.del-tag').getAttribute('data-email'),
													username = item.querySelector('a').innerText;
												$eachman += '<span usercode="'+usercode+'" certcode="'+certcode+'" deptname="'+deptname+'" phone="'+phone+'" email="'+email+'">'+username+'</span>、';
											})
											$('.review-value-box').html($eachman);
										}else{
											var selectAudit = JSON.parse($(lay).find('.data-audit-container').val());
											$('.audit-value-box').html(JSON.stringify(selectAudit.join(',')).replace(/"/g, ''));
										}
										layer.close(index);
									});
								});
							}
						})
					}
				}
			})
		});
	}

</script>